home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User: The RISC OS Graphics CD
/
Acorn User: The RISC OS Graphics CD.iso
/
utilities
/
grphpaper
/
_grphpaper
/
wwv2data
< prev
Wrap
Text File
|
1999-02-03
|
12KB
|
530 lines
# WimpWorks Information File
# WimpWorks © Jaffa Software 1996-8. All rights reserved.
DEF TASKdetails
Name GrphPaper
Purpose To make graph paper
Author © Victor Markwart
Licence Freeware
Version 0.03 (3 Feb 1999)
Compress True
Memory 0K
IconbarSide Right
IconbarPriority &00000000
IconbarSprite !grphpaper
IconbarText
ENDTASK
DEF WEMinclude
DrawWEM
Starter Pack
ENDWEM
DEF MENUiconMenu%
GrphPaper
Info
S(infoWindow%)
Help
PROCopen_help
Quit
CLOSEDOWN
ENDMENU
DEF SUBR_PROCiconclick
Event 3
Every -1
DEF PROCiconclick(button%)
CASE button% OF
WHEN 4:
PROCmouse(mx%, my%, mb%, window, icon)
MOVEWINDOW(graphpaper1, mx%-300, my%+600)
OPENWINDOW(graphpaper1)
WHEN 1:
IF created=TRUE THEN OPENWINDOW(display)
ENDCASE
ENDPROC
ENDSUBR
DEF SUBR_PROCwindow_klik
Event 12
Every -1
DEF PROCwindow_klik(window%, icon%, button%)
LOCAL a$
CASE window% OF
WHEN graphpaper1
a$=READICON(window%, xmaj_no_icn)
IF a$="" THEN
a$="28"
ENDIF
xmaj_div%=VAL(a$)
a$=READICON(window%, xmin_no_icn)
IF a$="" THEN
a$="5"
ENDIF
xmin_div%=VAL(a$)
a$=READICON(window%, ymaj_no_icn)
IF a$="" THEN
a$="20"
ENDIF
ymaj_div%=VAL(a$)
a$=READICON(window%, ymin_no_icn)
IF a$="" THEN
a$="5"
ENDIF
ymin_div%=VAL(a$)
CASE icon% OF
WHEN 21:
SETICON(window%, 7, "x-axis")
SETICON(window%, 8, "y-axis")
HIDEICON(window%, 23, 0)
HIDEICON(window%, 24, 0)
HIDEICON(window%, 25, 0)
HIDEICON(window%, 26, 0)
WHEN 22:
SETICON(window%, 7, "radial")
SETICON(window%, 8, "orbital")
HIDEICON(window%, 23, 1)
HIDEICON(window%, 24, 1)
HIDEICON(window%, 25, 1)
HIDEICON(window%, 26, 1)
WHEN xmaj_up_icn:
xmaj_div%+=1
IF xmaj_div%>99 THEN xmaj_div%=99
SETICON(window%, xmaj_no_icn, STR$(xmaj_div%))
WHEN xmaj_down_icn:
xmaj_div%-=1
IF xmaj_div%<1 THEN xmaj_div%=1
SETICON(window%, xmaj_no_icn, STR$(xmaj_div%))
WHEN xmin_up_icn:
xmin_div%+=1
IF xmin_div%>10 THEN xmin_div%=10
SETICON(window%, xmin_no_icn, STR$(xmin_div%))
WHEN xmin_down_icn:
xmin_div%-=1
IF xmin_div%<1 THEN xmin_div%=1
SETICON(window%, xmin_no_icn, STR$(xmin_div%))
WHEN ymaj_up_icn:
ymaj_div%+=1
IF ymaj_div%>99 THEN ymaj_div%=99
SETICON(window%, ymaj_no_icn, STR$(ymaj_div%))
WHEN ymaj_down_icn:
ymaj_div%-=1
IF ymaj_div%<1 THEN ymaj_div%=1
SETICON(window%, ymaj_no_icn, STR$(ymaj_div%))
WHEN ymin_up_icn:
ymin_div%+=1
IF ymin_div%>10 THEN ymin_div%=10
SETICON(window%, ymin_no_icn, STR$(ymin_div%))
WHEN ymin_down_icn:
ymin_div%-=1
IF ymin_div%<1 THEN ymin_div%=1
SETICON(window%, ymin_no_icn, STR$(ymin_div%))
WHEN icn_cancel:
CLOSEWINDOW(graphpaper1)
WHEN icn_create:
style%=GROUPSTATE(graphpaper1, 1) - 21
xmaj_scale%=GROUPSTATE(graphpaper1, 2) - 23
xmin_scale%=GROUPSTATE(graphpaper1, 3) - 25
ymaj_scale%=GROUPSTATE(graphpaper1, 4) - 27
ymin_scale%=GROUPSTATE(graphpaper1, 5) - 29
xmaj_col%=GROUPSTATE(graphpaper1, 6) - 42
xmin_col%=GROUPSTATE(graphpaper1, 7) - 58
ymaj_col%=GROUPSTATE(graphpaper1, 8) - 74
ymin_col%=GROUPSTATE(graphpaper1, 9) - 90
OPENWINDOW(display)
CASE button% OF
WHEN 4:
CLOSEWINDOW(graphpaper1)
WHEN 1:
OPENWINDOW(graphpaper1)
ENDCASE
PROCGraphPaper
ENDCASE
WHEN display
CASE button% OF
WHEN 1:
OPENWINDOW(graphpaper1)
WHEN 2:
a$=STR$(xmaj_div%)+"x"+STR$(ymaj_div%)
SETSAVE("Graph"+a$, "file_aff")
OPENSAVE
WHEN 4:
CLOSEWINDOW(display)
ENDCASE
ENDCASE
ENDPROC
ENDSUBR
DEF SUBR_PROCmouse
Event -1
Every -1
DEF PROCmouse(RETURN mx%, RETURN my%, RETURN mb%, RETURN window, RETURN icon)
SYS "Wimp_GetPointerInfo",,workspace%
mx%= workspace%!0
my%= workspace%!4
mb%= workspace%!8
window= workspace%!12
icon= workspace%!16
ENDPROC
ENDSUBR
DEF SUBR_PROCstart_up
Event 0
Every -1
DEF PROCstart_up
DIM workspace% 20
DIM colour%(17)
DIM scale%(2)
created=FALSE
scale%(0)=46080
scale%(1)=18142
xmaj_no_icn=31
xmaj_down_icn=32
xmaj_up_icn=33
xmin_no_icn=34
xmin_down_icn=35
xmin_up_icn=36
ymaj_no_icn=37
ymaj_down_icn=38
ymaj_up_icn=39
ymin_no_icn=40
ymin_down_icn=41
ymin_up_icn=42
icn_cancel=107
icn_create=108
style%=0
xmaj_scale%=1
xmin_scale%=0
ymaj_scale%=1
ymin_scale%=0
xmaj_div%=20
xmin_div%=5
ymaj_div%=28
ymin_div%=5
xmaj_sel%=51
xmin_sel%=74
ymaj_sel%=83
ymin_sel%=106
colour%(1)=&ffffff00
colour%(2)=&d0d0d000
colour%(3)=&b0b0b000
colour%(4)=&90909000
colour%(5)=&70707000
colour%(6)=&50505000
colour%(7)=&30303000
colour%(8)=&00000000
colour%(9)=&90400000
colour%(10)=&00e0e000
colour%(11)=&00c00000
colour%(12)=&0000d000
colour%(13)=&b0e0e000
colour%(14)=&00805000
colour%(15)=&00b0ff00
colour%(16)=&ffb00000
SETSTATE(graphpaper1,xmaj_sel%,TRUE)
SETSTATE(graphpaper1,xmin_sel%,TRUE)
SETSTATE(graphpaper1,ymaj_sel%,TRUE)
SETSTATE(graphpaper1,ymin_sel%,TRUE)
xmaj_col%=colour%(xmaj_sel% - 42)
xmin_col%=colour%(xmin_sel% - 58)
ymaj_col%=colour%(ymaj_sel% - 74)
ymin_col%=colour%(ymin_sel% - 90)
REM Radio buttons
SETSTATE(graphpaper1, 21, TRUE)
SETSTATE(graphpaper1, 24, TRUE)
SETSTATE(graphpaper1, 25, TRUE)
SETSTATE(graphpaper1, 28, TRUE)
SETSTATE(graphpaper1, 29, TRUE)
REM Colours
SETICON(graphpaper1, 31, STR$(xmaj_div%))
SETICON(graphpaper1, 34, STR$(xmin_div%))
SETICON(graphpaper1, 37, STR$(ymaj_div%))
SETICON(graphpaper1, 40, STR$(ymin_div%))
ENDPROC
ENDSUBR
DEF SUBR_PROCGraphPaper
Event -1
Every -1
DEF PROCGraphPaper
CLWIN(display)
created=TRUE
font_handle%=0
IF style%=0 THEN
xmax%=xmaj_div% * scale%(xmaj_scale%)
ymax%=ymaj_div% * scale%(ymaj_scale%)
ELSE
xmax%=ymaj_div% * scale%(ymaj_scale%) * 2
ymax%=xmax%
xorigin%=ymaj_div% * scale%(ymaj_scale%)
yorigin%=xorigin%
ENDIF
HOURON
DRAW_INIT(1)
DRAW_FONT("Homerton.Medium", font_handle%)
IF style%=0 THEN
REM Rectangular
DRAW_STARTPATH(-1, colour%(xmaj_col%), 0)
xinc%=scale%(xmaj_scale%)
DRAW_MOVE(0, 0)
DRAW_LINE(0, ymax%)
FOR j=0 TO xmaj_div%
xstep%=j * xinc%
DRAW_MOVE(xstep%, 0)
DRAW_LINE(xstep%, ymax%)
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(xmin_col%), 1)
xstep2%=xinc%/xmin_div%
FOR j=0 TO (xmaj_div% - 1)
xstep%=j * xinc%
FOR k=1 TO (xmin_div% - 1)
IF xmin_scale%=0 THEN
xstep2a%=xstep% + xstep2% * k
ELSE
xstep2a%=xstep% + (LOG(1 + k*9/xmin_div%))*xinc%
ENDIF
DRAW_MOVE(xstep2a%, 0)
DRAW_LINE(xstep2a% , ymax%)
NEXT
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(ymaj_col%), 1)
yinc%=scale%(ymaj_scale%)
DRAW_MOVE(0, 0)
DRAW_LINE(xmax%, 0)
FOR j=0 TO ymaj_div%
ystep%=j * yinc%
DRAW_MOVE(0, ystep%)
DRAW_LINE(xmax%, ystep%)
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(ymin_col%), 1)
ystep2%=yinc%/ymin_div%
FOR j=0 TO (ymaj_div% - 1)
ystep%=j * yinc%
FOR k=1 TO (ymin_div% - 1)
IF ymin_scale%=0 THEN
ystep2a%=ystep% + ystep2% * k
ELSE
ystep2a%=ystep% + LOG(1 + k*9/ymin_div%)*yinc%
ENDIF
DRAW_MOVE(0, ystep2a%)
DRAW_LINE(xmax%, ystep2a%)
NEXT
NEXT
DRAW_ENDPATH
ELSE
REM POLAR
DRAW_STARTPATH(-1, colour%(xmaj_col%), 0)
inc_angle=2 * PI /xmaj_div%
FOR j=0 TO xmaj_div%
angle=j * inc_angle
x%=COS(angle)*xorigin% + xorigin%
y%=SIN(angle)*xorigin% + xorigin%
DRAW_MOVE(xorigin%, yorigin%)
DRAW_LINE(x%, y%)
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(xmin_col%), 1)
min_angle=inc_angle / xmin_div%
FOR j=0 TO (xmaj_div% - 1)
maj_angle=j * inc_angle
FOR k=1 TO (xmin_div% - 1)
angle = maj_angle + k* min_angle
x%=COS(angle)*xorigin% + xorigin%
y%=SIN(angle)*xorigin% + xorigin%
DRAW_MOVE(xorigin%, yorigin%)
DRAW_LINE(x%, y%)
NEXT
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(ymaj_col%), 1)
yinc%=scale%(ymaj_scale%)
FOR j=0 TO ymaj_div%
ystep%=j * yinc%
PROCdraw_circle(xorigin%, yorigin%, ystep%)
NEXT
DRAW_ENDPATH
DRAW_STARTPATH(-1, colour%(ymin_col%), 1)
ystep2%=yinc%/ymin_div%
FOR j=0 TO (ymaj_div% - 1)
ystep%=j * yinc%
FOR k=1 TO (ymin_div% - 1)
IF ymin_scale%=0 THEN
ystep2a%=ystep% + ystep2% * k
ELSE
ystep2a%=ystep% + LOG(1 + k*9/ymin_div%)*yinc%
ENDIF
PROCdraw_circle(xorigin%, yorigin%, ystep2a%)
NEXT
NEXT
DRAW_ENDPATH
ENDIF
HOUROFF
drawfile%=DRAW_FILE
drawsize%=DRAW_SIZE
file$=FNscrap_dir+".GraphPaper"
DRAW_SAVE(file$)
DRAW_EXIT
RELEASE(drawfile%)
drawfile%=LOADFILE(file$)
IF drawfile%=-1 THEN WARNING(TOKEN("NoMem"), "GraphPaper")
SYS "OS_File",17,file$ TO ,,,,drawsize%
percenty%=1024*256*100/ymax%
percentx%=1280*256*100/xmax%
percent%=FNmin(percentx%, percenty%)
DRAW(display, 0, 0, 100,percent%,drawfile%, drawsize%)
ENDPROC
ENDSUBR
DEF SUBR_PROCsquare
Event -1
Every -1
DEF PROCsquare(minx%, miny%, maxx%, maxy%)
DRAW_MOVE(minx%, miny%)
DRAW_LINE(minx%, maxy%)
DRAW_LINE(maxx%, maxy%)
DRAW_LINE(maxx%, miny%)
DRAW_LINE(minx%, miny%)
ENDPROC
ENDSUBR
DEF SUBR_FNscrap_dir
Event -1
Every -1
DEF FNscrap_dir
LOCAL a$
a$=OSVAR("Wimp$ScrapDir")
IF a$="" THEN
MESSAGE("Unable to find 'Wimp$ScrapDir'. Please show the system the !Scrap application", "GraphPaper Error","warning","OK","","","")
ENDIF
=a$
ENDSUBR
DEF SUBR_FNsave_file
Event 8
Every -1
DEF FNsave_file(file$)
LOCAL a$, b$
b$=FNscrap_dir
IF b$<>"" THEN
a$= "copy " + b$ +".GraphPaper " + file$ + " A~CDFL~V"
SYS "XOS_CLI", a$
ENDIF
=0
ENDSUBR
DEF SUBR_FNmin
Event -1
Every -1
DEF FNmin(x , y)
IF x<y THEN =x ELSE =y
ENDSUBR
DEF SUBR_PROCdraw_circle
Event -1
Every -1
DEF PROCdraw_circle(x, y, r)
LOCAL v
v = .55 * r
DRAW_MOVE(x, y + r)
DRAW_CURVE(x + r, y, x + v, y + r, x + r, y + v)
DRAW_CURVE(x, y - r, x + r, y - v, x + v, y - r)
DRAW_CURVE(x - r, y, x - v, y - r, x - r, y - v)
DRAW_CURVE(x, y + r, x - r, y + v, x - v, y + r)
ENDPROC
ENDSUBR
DEF SUBR_PROCopen_help
Event -1
Every -1
DEF PROCopen_help
LOCAL a$
a$="Filer_Run <GrphPaper$Dir>.!Help"
OSCLI a$
ENDPROC
ENDSUBR
DEF SUBR_PROCdraw_ellipse
Event -1
Every -1
DEF PROCdraw_ellipse(x0, y0, x1, y1, x2, y2)
LOCAL x3, y3, x4, y4
IF x1 > x2 THEN
SWAP x1, x2
SWAP y1, y2
ENDIF
x3=2*x0 - x1
y3=2*y0 - y1
x4=2*x0 - x2
y4=2*y0 - y2
IF y3 > y1 THEN
SWAP x1, x3
SWAP y1, y3
ENDIF
IF x2 < x4 THEN
SWAP x2, x4
SWAP y2, y4
ENDIF
WARNING(STR$(x0) + " " +STR$(x1)+" "+STR$(x2)+" "+STR$(x3)+" "+STR$(x4), "Ellipse")
xrmaj=(x2 - x0)*.55
xrmin=ABS((x1 - x0)*.55)
yrmaj=(y1 - y0)*.55
yrmin=ABS((y2 - y0)*.55)
DRAW_MOVE(x1, y1)
IF y2 > y4 THEN
DRAW_CURVE(x2, y2, x1 + xrmaj, y1 + yrmin, x2 - xrmin, y2 + yrmaj)
DRAW_CURVE(x3, y3, x2 + xrmin, y2 - yrmaj, x3 + xrmaj, y3 + yrmin)
DRAW_CURVE(x4, y4, x3 - xrmaj, y3 - yrmin, x4 + xrmin, y4 - yrmaj)
DRAW_CURVE(x1, y1, x4 - xrmin, y4 + yrmaj, x1 - xrmaj, y1 - yrmin)
ELSE
DRAW_CURVE(x2, y2, x1 + xrmaj, y1 - yrmin, x2 - xrmin, y2 - yrmaj)
DRAW_CURVE(x3, y3, x2 + xrmin, y2 + yrmaj, x3 + xrmaj, y3 - yrmin)
DRAW_CURVE(x4, y4, x3 - xrmaj, y3 + yrmin, x4 + xrmin, y4 + yrmaj)
DRAW_CURVE(x1, y1, x4 - xrmin, y4 - yrmaj, x1 - xrmaj, y1 + yrmin)
ENDIF
ENDPROC
ENDSUBR